package com.creawor.hz_market.resource.community_resource;

import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;

import com.creawor.hz_market.servlet.LoadMapInfoAjax;
import com.creawor.imei.base.AbsQueryMap;

public class CommunityResource_QueryMap extends AbsQueryMap {
	private static final Logger logger = Logger.getLogger(LoadMapInfoAjax.class);
public CommunityResource_QueryMap() throws HibernateException {
	this.initSession();
}

public Iterator findAll() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from CommunityResource").next()).intValue();
	String querystr = "from CommunityResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.iterate();
}
public List findAllList() throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from CommunityResource").next()).intValue();
	String querystr = "from CommunityResource";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}
public List findAllByCounty(String county) throws HibernateException {
	this.totalrow =	((Integer) this.session.iterate("select count(*) from CommunityResource where county ='"+county+"'").next()).intValue();
	String querystr = "from CommunityResource as t where t.county ='"+county+"'";
	Query query = this.session.createQuery(querystr);
  this.setQueryPage(query);
	return query.list();
}

public CommunityResource_Form getByID(String ID) throws HibernateException {
	CommunityResource_Form  vo = null;

//System.out.println("\nt_group_QueryMap getByID:"+ID);
logger.debug("\nCommunityResource_QueryMap getByID:"+ID);

	this.session.clear();
	try {
		vo =new CommunityResource_Form();
		CommunityResource po=(CommunityResource) this.session.load(CommunityResource.class, new Integer(ID));

try{
  vo.setId(String.valueOf(po.getId()));
}catch (Exception e) {
	    e.printStackTrace();
}
vo.setCompany(po.getCompany());
vo.setCounty(po.getCounty());

try{
	vo.setCommunityNum(String.valueOf(po.getCommunityNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setFamilyNum(String.valueOf(po.getFamilyNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setYdTelNum(String.valueOf(po.getYdTelNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setGdTelNum(String.valueOf(po.getGdTelNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}

try{
	vo.setKdNum(String.valueOf(po.getKdNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setCdmaNum(String.valueOf(po.getCdmaNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
try{
	vo.setXiaoltNum(String.valueOf(po.getXiaoltNum()));
	}catch (Exception e) {
	    e.printStackTrace();
	}
	try{
		vo.setBeizhu(String.valueOf(po.getBeizhu()));
		}catch (Exception e) {
		    e.printStackTrace();
		}
try{
	    vo.setUpdatedDay(com.creawor.km.util.DateUtil.getStr(po.getUpdatedDay(),"yyyy-MM-dd"));
	    vo.setInsertDay(com.creawor.km.util.DateUtil.getStr(po.getInsertDay(),"yyyy-MM-dd"));
	  }catch (Exception e) {
		    e.printStackTrace();
	  }



	} catch (HibernateException e) {
		
		logger.debug("\nERROR in getByID @communityresource:" + e);
	}
	return vo;
}	

}
//����������


